package com.example.demo0.service;

import com.example.demo0.entity.User;
import com.example.demo0.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper; // Injects the UserMapper bean

    public List<User> getAllUsers() {
        return userMapper.selectList(null); // Queries all users from the database
    }

    public User getUserWithRoleById(Long id) {
        return userMapper.selectUserWithRoleById(id); // Fetches user with role by ID
    }
}